﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using NETWORKADMIN;
using System.Timers;
using AccionesWindows;

namespace ClClientService
{
    public partial class CyberService : ServiceBase
    {
        //public LogWindows logw;
        public CyberService()
        {
            InitializeComponent();
        }
        NetAdminServer n;
        System.Timers.Timer otime;
        bool activado;
        protected override void OnStart(string[] args)
        {
            activado = false;
            otime = new System.Timers.Timer(1000);
            otime.Elapsed += new ElapsedEventHandler(timer_Elapsed);
            otime.Enabled = true;
            otime.Start();
           // logw = new LogWindows("En Metodo OnStart Lmcc");
            
        }



        private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {

            if (activado == false)
            {
                try
                {
                    n = new NetAdminServer();
                    n.StartListening();
                    activado = true;
                }
                catch (Exception ex)
                {
                   // logw = new LogWindows("Error en Evento Timer de onStart, error: " + ex.Message);
                   
                }
            }
        }

        protected override void OnStop()
        {
            otime.Stop();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {

        }

        private void eventLog1_EntryWritten(object sender, EntryWrittenEventArgs e)
        {

        }
    }
}
